<?
class pub
{	
	public $sql			= '';
	public function pub(){
		
	}
	
// 	public function pub($sql,$lang_id,$parent_id,$child_id,$childsub_id){
		
// 		$this->sql			= $sql;
// 		$this->lang_id		= $lang_id;
// 		$this->parent_id	= $parent_id;
// 		$this->child_id		= $child_id;
// 		$this->childsub_id	= $childsub_id;
// 	}
	public function direct($page,$info){
	
		$str='<br><br><table width="450" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" bordercolor="#F7F3F3">
		<tr><td>
		<table width="100%"   border="0" align="center" cellpadding="0" cellspacing="0">
		  <tr>
			<td height="30" bgcolor="#2f66a7" align="center" ><font size="2" color="white"><B>THÔNG BÁO</B></font></td>
		  </tr>
		  <tr>
			<td height="70" style="font-size:12px; color:#339933; font-family:Tahoma; " align="center">'.$info.'</td>
		  </tr>
		  <tr>
			<td height="20" align="center" >&nbsp;&nbsp;<img src="image/wait.gif"></td>
		  </tr>
		</table>
		</td></tr></table><br><br>
		<meta http-equiv="refresh" content="2;url='.$page.'">';
		return $str;	
	}
	public function direct1($page,$info){
	
		$str='<br><br><table width="450" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" bordercolor="#F7F3F3">
		<tr><td>
		<table width="100%"   border="0" align="center" cellpadding="0" cellspacing="0">
		  <tr>
			<td height="30" bgcolor="#2f66a7" align="center" ><font size="2" color="white"><B>THÔNG BÁO</B></font></td>
		  </tr>
		  <tr>
			<td height="70" style="font-size:12px; color:#339933; font-family:Tahoma; " align="center">'.$info.'</td>
		  </tr>
		  <tr>
			<td height="20" align="center" >&nbsp;&nbsp;<img src="image/wait.gif"></td>
		  </tr>
		</table>
		</td></tr></table><br><br>
		<meta http-equiv="refresh" content="30;url='.$page.'">';
		return $str;	
	}
	public function redirect($time,$page) {
		
		if (preg_match("/\b;\b/i",$page)) {
			return '<script language="JavaScript" type="text/javascript"> top.location =("'.$page.'"); </script>';
		}
		else 		
			return '<meta http-equiv="refresh" content="'.$time.';url='.$page.'">';
	} 
	
	
	function paging($frm_function,$totalrows,$curpg,$pg,$re) {	 
		
		$curpage 	= $curpg;// Trang hiện tại
      	$maxpage 	= $pg; // Số trang hiện ra
      	$paging_java= "";			  
     	// $maxcurpage=;
      	$mxr 		= $re;     
        // Tong so trang=tong so hang/so hang moi trang
        // Neu co so du thi tong so trang cong them 1       		
		if ($totalrows % $mxr == 0)
       	  		$totalpage = (int)($totalrows / $mxr);
				// Tổng số trang = Tổng số dòng/ Số dòng phân trang
       	else
       	  		$totalpage = (int)($totalrows / $mxr + 1);
								
      	// Khai bao bien so hang hien tai bat dau tu hang thu i
      	$currow = ($curpage - 1) * $mxr + 1;                
		// Gan bien chuoi paging de tra ve
		if($curpage == "")
        		$curpage = 1;
       	 else
        	 	$curpage = $curpage;
       
     	//Hien thi so trang			 
		if($totalrows > $mxr){
          
             $minp = 1;
             $maxp = 1;
             $paging1 = "";
			 
          //Dinh nghia chuoi (1 2 3 4)
		  
          	for ($i = 1 ; $i <= $totalpage ; $i++){
			
                if (($i >  ((int)(($curpage - 1) / $maxpage    )) * $maxpage) &&
                    ($i <= ((int)(($curpage - 1) / $maxpage + 1)) * $maxpage)){
						//$paging1 .= ((int)((($curpage - 1) / $maxpage    )) * $maxpage);
                    	//$paging1 .= ((int)(((($curpage - 1) / $maxpage + 1)) * $maxpage));					
                   	 if ($minp == 1) $minp = $i;
					 
                   	if ($i == $curpage) {
                   		if($i!=$maxpage) $paging1 .= '<span class="paging_active">'.$i.'</span>|&nbsp;';
                   		else $paging1 .= '<span class="paging_active">'.$i.'</span>&nbsp;';
                   	}
                   	 else {
                   	 	if($i!=$maxpage)
                   	 		$paging1 .= "<a href='javascript: ".$frm_function."(".$i.")'>$i</a>|&nbsp;";
                   	 	else 	
                   	 		$paging1 .= "<a href='javascript: ".$frm_function."(".$i.")''>$i</a>&nbsp;"; 					 	
                   	}
						 
                     $maxp = $i;
                     //$paging1 .= $maxp;
					 
                 }//End if (($i>((int)(($curpage-1)/$maxpage))*$maxpage))&&
                   //     ($i>((int)(($curpage-1)/$maxpage+1))*$maxpage)) 
             }//for
			  
      //   $paging .= "Go To Page :&nbsp;&nbsp;";
			 $paging_java .= "<a href='javascript: ".$frm_function."(1)'><img src='".PATH_HTTP."image/btn/btn_first.gif' border='0' align='absmiddle'></a>&nbsp;&nbsp;";	
      	
	       	 //if ($curpage > $maxpage) 
	       	if($curpage > 0 && $curpage > $maxpage)    
	        	$paging_java .= "<a href='javascript: ".$frm_function."(".($minp-1).")'><img src='".PATH_HTTP."image/btn/btn_pre.gif' border='0' align='absmiddle'></a>&nbsp;&nbsp;";
	        else 
				$paging_java .= "<img src='".PATH_HTTP."image/btn/btn_pre.gif' border='0' align='absmiddle'>&nbsp;&nbsp;&nbsp;";
				
	         $paging_java .= $paging1; 
			 
	         // Khai bao Next
	         // if (((($curpage-1)/$maxp+1 )*$maxpage )<$totalpage)
	
	         //if (($curpage < $totalpage) && (($maxp % $maxpage) == 0) && ($maxp < $totalpage))
	         if($curpage < $totalpage)
	              	$paging_java .= "&nbsp;&nbsp;<a href='javascript: ".$frm_function."(".($maxp+1).")'><img src='".PATH_HTTP."image/btn/btn_next.gif' border='0' align='absmiddle'></a>&nbsp;&nbsp;";
			else 
					$paging_java .= "&nbsp;&nbsp;<img src='".PATH_HTTP."image/btn/btn_next.gif' border='0' align='absmiddle'>&nbsp;&nbsp;";		
					
			//End total page		
	        $paging_java .= "<a href='javascript: ".$frm_function."($totalpage)'><img src='".PATH_HTTP."image/btn/btn_last.gif' border='0' align='absmiddle'></a>&nbsp;&nbsp;";	      
		  }	 // End if($totalrows > $mxr) 

          
		  return $paging_java;
	
	} 
	
	
	public function paging_java($frm_function,$totalrows,$curpg,$pg,$re) {	 
		
		$curpage 	= $curpg;
      	$maxpage 	= $pg;
      	$maxrow  	= $re;
      	$paging_java= "";			  
     	// $maxcurpage=;
      	$mxr 		= $maxrow;
      
        // Tong so trang=tong so hang/so hang moi trang
        // Neu co so du thi tong so trang cong them 1       		
		if ($totalrows % $mxr == 0)
       	  		$totalpage = (int)($totalrows / $mxr);
       	else
       	  		$totalpage = (int)($totalrows / $mxr + 1);
				
      	// Khai bao bien so hang hien tai bat dau tu hang thu i
      	$currow = ($curpage - 1) * $mxr + 1;
                
		// Gan bien chuoi paging de tra ve
		if($curpage == "")
        		$curpage = 1;
       	 else
        	 	$curpage = $curpage;

       /*
          	 $paging_java  = "<font color='#009900'>Trang Hiện Tại :&nbsp;&nbsp";
         	 $paging_java .= $curpage."&nbsp;&nbsp;&nbsp;&nbsp;";
          	 $paging_java .= "Tổng Số Trang :&nbsp;&nbsp;";
          	 $paging_java .= $totalpage."</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        */ 	  
       
     	//Hien thi so trang			 
		if($totalrows > $mxr){
          
             $minp = 1;
             $maxp = 1;
             $paging1 = "";
			 
          //Dinh nghia chuoi (1 2 3 4)
		  
          	for ($i = 1 ; $i <= $totalpage ; $i++){
			
                if (($i >  ((int)(($curpage - 1) / $maxpage    )) * $maxpage) &&
                    ($i <= ((int)(($curpage - 1) / $maxpage + 1)) * $maxpage)){
						//$paging1 .= ((int)((($curpage - 1) / $maxpage    )) * $maxpage);
                    	//$paging1 .= ((int)(((($curpage - 1) / $maxpage + 1)) * $maxpage));					
                   	 if ($minp == 1) $minp = $i;
					 
                   	if ($i == $curpage) {
                   		if($i!=$maxpage) $paging1 .= '<span class="paging_active">'.$i.'</span>|&nbsp;';
                   		else $paging1 .= '<span class="paging_active">'.$i.'</span>&nbsp;';
                   	}
                   	 else {
                   	 	if($i!=$maxpage)
                   	 		$paging1 .= "<a href='javascript: ".$frm_function."(".$i.")'>$i</a>|&nbsp;";
                   	 	else 	
                   	 		$paging1 .= "<a href='javascript: ".$frm_function."(".$i.")''>$i</a>&nbsp;"; 					 	
                   	}
						 
                     $maxp = $i;
                     //$paging1 .= $maxp;
					 
                 }//End if (($i>((int)(($curpage-1)/$maxpage))*$maxpage))&&
                   //     ($i>((int)(($curpage-1)/$maxpage+1))*$maxpage)) 
             }//for
			  
         // Gan Previous neu curpage lon hon 1
		
      //   $paging .= "Go To Page :&nbsp;&nbsp;";
			 $paging_java .= "<a href='javascript: ".$frm_function."(1)'><img src='".PATH_HTTP."image/btn/btn_first.gif' border='0' align='absmiddle'></a>&nbsp;&nbsp;";	
      	
	       	 //if ($curpage > $maxpage) 
	       	if($curpage > 0 && $curpage > $maxpage)    
	        	$paging_java .= "<a href='javascript: ".$frm_function."(".($minp-1).")'><img src='".PATH_HTTP."image/btn/btn_pre.gif' border='0' align='absmiddle'></a>&nbsp;&nbsp;";
	        else 
				$paging_java .= "<img src='".PATH_HTTP."image/btn/btn_pre.gif' border='0' align='absmiddle'>&nbsp;&nbsp;&nbsp;";
				
	         $paging_java .= $paging1; 
			 
	         // Khai bao Next
	         // if (((($curpage-1)/$maxp+1 )*$maxpage )<$totalpage)
	
	         //if (($curpage < $totalpage) && (($maxp % $maxpage) == 0) && ($maxp < $totalpage))
	         if($curpage < $totalpage)
	              	$paging_java .= "&nbsp;&nbsp;<a href='javascript: ".$frm_function."(".($maxp+1).")'><img src='".PATH_HTTP."image/btn/btn_next.gif' border='0' align='absmiddle'></a>&nbsp;&nbsp;";
			else 
					$paging_java .= "&nbsp;&nbsp;<img src='".PATH_HTTP."image/btn/btn_next.gif' border='0' align='absmiddle'>&nbsp;&nbsp;";		
					
			//End total page		
	        $paging_java .= "<a href='javascript: ".$frm_function."($totalpage)'><img src='".PATH_HTTP."image/btn/btn_last.gif' border='0' align='absmiddle'></a>&nbsp;&nbsp;";	      
		  }	 // End if($totalrows > $mxr) 

          
		  return $paging_java;
	
	} // paging_java2	

	
	function CutStr($st) {
			$str = trim($st);
			$str = preg_replace("/(à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/", 'a', $str);
			$str = preg_replace("/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/", 'e', $str);
			$str = preg_replace("/(ì|í|ị|ỉ|ĩ)/", 'i', $str);
			$str = preg_replace("/(ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/", 'o', $str);
			$str = preg_replace("/(ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ)/", 'u', $str);
			$str = preg_replace("/(ỳ|ý|ỵ|ỷ|ỹ)/", 'y', $str);
			$str = preg_replace("/(đ)/", 'd', $str);
			$str = preg_replace("/(À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ)/", 'A', $str);
			$str = preg_replace("/(È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ)/", 'E', $str);
			$str = preg_replace("/(Ì|Í|Ị|Ỉ|Ĩ)/", 'I', $str);
			$str = preg_replace("/(Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ)/", 'O', $str);
			$str = preg_replace("/(Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ)/", 'U', $str);
			$str = preg_replace("/(Ỳ|Ý|Ỵ|Ỷ|Ỹ)/", 'Y', $str);
			$str = preg_replace("/(Đ)/", 'D', $str);
			//$str = str_replace(" ", "-", str_replace("&*#39;","",$str));
			
			$str = str_replace(" / ","-",$str);
			$str = str_replace("/","-",$str);
			$str = str_replace(" - ","-",$str);
			$str = str_replace("_","-",$str);
			$str = str_replace(" ", "-", $str);
			$str = str_replace( "ß", "ss", $str);
			$str = str_replace( "&", "", $str);
			$str = str_replace( "%", "", $str);
			$str = preg_replace("[^A-Za-z0-9-]", "", $str);
			
			$str = str_replace("----","-",$str);
			$str = str_replace("---","-",$str);
			$str = str_replace("--","-",$str);
	
	
		return $str;
	
	}				

	public function random(){
	
		$pass = "";
		$chars = array(
			"1","2","3","4","5","6","7","8","9","0",
			"a","A","b","B","c","C","d","D","e","E","f","F","g","G","h","H","i","I","j","J",
			"k","K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R","s","S","t","T",
			"u","U","v","V","w","W","x","X","y","Y","z","Z");
	
		$count = count($chars) - 1;
		srand((double)microtime()*1000000);
		for($i = 0 ; $i < 9 ; $i++){		
			$pass .= $chars[rand(0, $count)];
		}	
		return $pass;
	}
	
	function bmax_i($a,$b) {
		
		$temp	='';
		$kq 	='';		
		if($a>$b) {
			$temp = $a-$b;
			$kq = $a-$temp;
		}
		return $kq;		
	}
	
	
		
		function visiter(){
		global $sql;
		$today	= date("Y-m-d");
		$mresult = $sql->query("SELECT dateadd FROM visistor WHERE dateadd='".$today."' ");
		if($sql->num_rows($mresult)>0){
			$result2 = $sql->query("UPDATE visistor SET number=number+1 WHERE dateadd='".$today."'");
		}else{
			$result2 = $sql->query("INSERT INTO visistor(dateadd,number) VALUES('".$today."','0')");
		}
			$sql->free_result($mresult);
		}
		function total_visiter(){
			global $sql;
			$sql->query("SELECT sum(number) as tongso FROM visistor");
			while($k=$sql->fetch_array()){
				$number = $k['tongso'];
			}
			return $number;
			$sql->free_result();
		}
		function Count_order(){
			global $sql;
			$result = $sql->query("SELECT COUNT(No) as tongso FROM movie_tpm WHERE tpm_session='".$_SESSION['hd308']."'");
			$number = 0;
			while($k=$sql->fetch_array($result)){
				$number = $k['tongso'];
			}
			return $number;
			$sql->free_result($result);
		}

		function visitcounter($No){
		global $sql;
			$result = $sql->query("UPDATE batdongsan SET luotxem=luotxem+1 WHERE No='".$No."'");
			$sql->free_result();
		}		
	function GetShowList(){		
	 global $sql;
	 	$show ='';
			$slt = "No,sub_id,title";
			$sql->query('SELECT '.$slt.' FROM batdongsan  WHERE active="1"   ORDER BY date_add DESC LIMIT 0,8');									
			while($k=$sql->fetch_array()){
				$name = pub::CutStr($k['title']);
				$link = ''.PATH_HTTP.'Ban-va-Thue/'.$k['sub_id'].'/'.$k['No'].'/'.$name.'.html';				
				$show .='<div style="height:35px; " ><a href="'.$link.'" class="linkgreen"> <img src="'.PATH_HTTP.'image/arrow.gif" align="absmiddle" /> '.pub::TrimStr($k['title'],43).'</a></div>
							  <div style="background-image:url('.PATH_HTTP.'image/line_width.gif); height:2px; "></div>';			
}
		return $show;		
		$sql->free_result();
	}		
	function GetTopMenu(){		
	 global $sql,$pub;
	 		$str ='';
			$query	=$sql->query('SELECT * FROM parent_cat  WHERE parent_active="1" AND parent_show="1" ORDER BY parent_order DESC');						
					$i= 2;
					$str .='<li ><a href="'.PATH_HTTP.'" class="linkwhite"><span><b>TRANG CHỦ</b></span></a></li>';
					while($k=mysql_fetch_array($query)){					
							$cut_name	= $pub->CutStr($k['parent_name']);
								if($k['parent_type']=="1" ){
									$link = PATH_HTTP.'Tin/'.$k['parent_id'].'/';
								}
								if($k['parent_type']=="2"){
									$link = PATH_HTTP.'Tin/'.$k['parent_id'].'/';
									
								}								
								if($k['parent_type']=="3"){
									$link = PATH_HTTP.'BDS/'.$k['parent_id'].'/';
								}								
								if($k['parent_type']=="4"){
									$link = PATH_HTTP.'BusinessNews/'.$k['parent_id'].'/';
								}																							
							$str .='<li><a href="'.$link.'" onmouseover="mopen(\'m'.$i.'\')" onmouseout="mclosetime()"  class="linkwhite"><span><b>'.$k['parent_name'].'</b></span></a>';
							$query_1	= mysql_query('SELECT * FROM subcate WHERE  parent_id="'.$k['parent_id'].'" AND sub_active="1" ORDER BY sub_order DESC');
							if($query_1 == true){																																																						
								$str .='<div id="m'.$i.'" onmouseover="mcancelclosetime()" onmouseout="mclosetime()" style="visibility: hidden; ">';
								while($m=mysql_fetch_array($query_1)){																
								$subname	= $pub->CutStr($m['sub_name']);			
									if($m['sub_type']=="1"){
										$mlink = PATH_HTTP.'Tin-tuc/'.$m['parent_id'].'/'.$m['sub_id'].'/';
									}
									if($m['sub_type']=="2"){
										$mlink = PATH_HTTP.'Tin-tuc/'.$m['parent_id'].'/'.$m['sub_id'].'/';
									}								
									if($m['sub_type']=="3"){
										$mlink = PATH_HTTP.'BDS_1/'.$m['parent_id'].'/'.$m['sub_id'].'/';
									}								
									if($m['sub_type']=="4"){
										$mlink = PATH_HTTP.''.$m['sub_link'].'';
									}						
										$str .='<a href="'.$mlink.'">'.$m['sub_name'].'</a>';																							
								}	
							}	
									
						$str.='</div></li>';
						$i++;
					}		
	//$sql->free_result($query);
	//$sql->free_result($query_1);
		return $str;
		
	}		

	function StrMoney($st) 
	{
		$arr_str = array();
		$i=0;  
		while(strlen($st)>3)
		{
				$arr_str[$i]=substr($st,-3);	
				$l = strlen($st)-3;
				$st=substr($st,0,$l);
				$i++;
		}
			$arr_str[$i] = $st;
			$j=$i; 
			while($j>=0)
			{
				if($j==0) {  $str .= $arr_str[$j]; }
				else { $str .= $arr_str[$j]."."; }					
				$j--;		
			}
		if((int)$str > 0) $str .=	'&nbsp;';
		else $str = '';
		return $str;
	}		
	
		
	
	
	function GetChating(){		
			$show ='';
			$result = mysql_query('SELECT  * FROM chating WHERE yahoo_active="1" ');			
			if($result == false){
				return '';
			}			
					while($k=mysql_fetch_array($result)){										
							$show .='<div style="height:26px; padding-left:10px; "><a href="ymsgr:sendIM?'.$k['yahoo_id'].'" style="text-decoration:none; color:red; font-weight:bold;"> <img src="http://opi.yahoo.com/online?u='.$k['yahoo_id'].'&m=g&t=0" border="0" />&nbsp;<font style="font-family:Tahoma; color:red; font-size:12px; "> '.$k['yahoo_name'].'</font></a></div>';
								
					}			
		return $show;
		mysql_free_result($result);
	}			
	function GetMobi(){		
		$show='';			
		$result = mysql_query('SELECT  * FROM mobi WHERE m_active="1" ');
		if($result == false){
			return '';
		}						
					while($k=mysql_fetch_array($result)){				
							$show .='<div style="height:26px; padding-left:10px; font-family:tahoma; font-size:14px; color:#009900; ">
							<img src="'.PATH_HTTP.'upload_img/'.$k['m_icon'].'" align="absbottom" />&nbsp;<b>'.$k['m_number'].'  </b></div>';
					}			
		return $show;
		mysql_free_result($result);
	}		
	function GetConfig($type){		
			$result = mysql_query('SELECT  * FROM config');
			if($result == false){
				return '';
			}						
					while($k=mysql_fetch_array($result)){				
						$show = $k[$type];
					}			
		return $show;
		mysql_free_result($result);
	}			

	function GetAdvert($area)
	{
		global $sql;
		$show = '';
		$sql->query("SELECT * FROM adv WHERE adv_area=".$area." ORDER BY adv_order DESC ");
		while ($rw=$sql->fetch_array()) {
			$file_type = array (".jpg",".gif",".bmp",".png",".GIF",".JPG",".BMP",".PNG");
			$ext = strrchr($rw['adv_img'],".");
			if (in_array($ext,$file_type)){
					$show .= '<div><a href="'.$rw['adv_link'].'" target="_blank"><img src="'.PATH_HTTP.'upload_img/'.$rw['adv_img'].'" width="218" height="314"  border="0" vspace="1" hspace="1"></a> </div>';
			}else{
					$show .='<div><script language="javascript">flash(\''.PATH_HTTP.'upload_img/'.$rw['adv_img'].'\',\'218\',\'314\',\'\',\'transparent\',\'\');</script></div>';		
			}
		}		
		$sql->free_result();
		return $show;
	}		
	
	function TrimStr($str, $len){
		$charset='UTF-8';
		$str = html_entity_decode($str, ENT_QUOTES, $charset);   
		if(mb_strlen($str, $charset)> $len){
			$arr = explode(' ', $str);
			$str = mb_substr($str, 0, $len, $charset);
			$arrRes = explode(' ', $str);
			$last = $arr[count($arrRes)-1];
			unset($arr); 
			if(strcasecmp($arrRes[count($arrRes)-1], $last))
			{
			 unset($arrRes[count($arrRes)-1]);
			}
		return implode(' ', $arrRes)."..";
		}
		return $str;
	}	
	
	
	
	function Login(){
		if($_SESSION['user_name']!=""){
		  $str ='<table width="100%"  border="0" cellspacing="0" cellpadding="0" >
		 
			<tr>
			  <td  align="right">Tên truy cập :&nbsp; </td>
			  <td  align="left">'.$_SESSION['user_name'].'</td>
					
			  <td   ><a href="'.PATH_HTTP.'Gio-hang/"  >&raquo;&nbsp;Giỏ hàng </a></td>			
			  <td  ><a href="'.PATH_HTTP.'Login/Logout/" >&raquo;&nbsp;Thoát </a></td>
			</tr>
			 </form>	
		  </table>';
		 }else{
			$str ='<table width="100%"  border="0" cellspacing="0" cellpadding="0"  >
		  <form method=post action="'.PATH_HTTP.'Login/">

			<tr>
			<td width="250px" >&nbsp; </td>
			  <td  >&nbsp;</td>
			  <td><a href="'.PATH_HTTP.'Register/">Đăng ký </a></td>
				<td>&nbsp;/&nbsp;</td>
			  <td><a href="'.PATH_HTTP.'Login/">Đăng nhập</a></td>
			</tr>						
			 </form>	
		  </table>';		 
		 }
		 return $str;
	}
	
	
	function ComBobox()
	{
		$result= mysql_query("SELECT * from parent WHERE  parent_active='1' and parent_type='3' ");	 
		if($result == false){
			return;
		}
          $show = "<select name='parent_id'   style='margin-top: 0px; margin-right: 10px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: middle; font-size: 12px; font-family: Arial; color: rgb(51, 51, 51); font: normal normal normal 1em/normal Arial, Helvetica, sans-serif; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(221, 221, 221); border-right-color: rgb(221, 221, 221); border-bottom-color: rgb(221, 221, 221); border-left-color: rgb(221, 221, 221); background-image: url(http://phimhd360.com/styles/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(238, 238, 238); border-top-left-radius: 4px 4px; border-top-right-radius: 4px 4px; border-bottom-right-radius: 4px 4px; border-bottom-left-radius: 4px 4px; height: 20px; line-height: 25px; background-position: 50% 0%; background-repeat: repeat no-repeat;'>";
          while($k=mysql_fetch_array($result)){
               $show .= '<option value="'.$k['parent_id'].'" >'.$k['parent_name'].'</option> \n' ;
          }
		  $show .='</select>';
		 return $show;
		 mysql_free_result($result);
	}
	function CBoxParentMovie()
	{
		$result= mysql_query("SELECT * from parent WHERE  parent_active='1' and parent_type='4' ");	 
		if($result == false){
			return;
		}
		  $show .="<option value='0' selected>Tất cả</option> ";
          while($k=mysql_fetch_array($result)){
               $show .= ' <option value="'.$k['parent_id'].'" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">'.$k['parent_name'].'</option> \n' ;
          }
		 return $show;
		 mysql_free_result($result);
	}	
	function CBoxMovie()
	{
		$result= mysql_query("SELECT * from subcat WHERE  sub_active='1' and sub_type='4' ");
		if($result == false){
			return;
		}	 
		  $show .="<option value='0' selected>Tất cả</option> ";
          while($k=mysql_fetch_array($result)){
               $show .= ' <option value="'.$k['sub_id'].'" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">'.$k['sub_name'].'</option> \n' ;
          }
		 return $show;
		 mysql_free_result($result);
	}		
	function tmpmovie($session_id,$id)
	{
		global $sql;
		$result = $sql->query("SELECT * FROM movie_tpm WHERE tpm_session='".$session_id."' AND mv_ID='".$id."'");
		if($result == false){
			return;
		}
		return $sql->num_rows($result);
	}
	function countTmpmovie($session_id)
	{
		global $sql;
		$result = $sql->query("SELECT * FROM movie_tpm WHERE tpm_session='".$session_id."'");
		if($result == false){
			return;
		}

		return $sql->num_rows($result);
	}
	function movie($id)
	{
		global $sql;
		$arr = array();
		$result = $sql->query("SELECT * FROM movie WHERE id='".$id."' AND mv_active=1");
		if($result == false){
			return;
		}
		while($rw=$sql->fetch_array($result)){
			$arr[0] = $rw['id'];
			$arr[1] = $rw['mv_id'];
			$arr[2] = $rw['parent_id'];
			$arr[3]	= $rw['sub_id'];
			$arr[4] = $rw['mv_name'];
			$arr[5]	= $rw['mv_smallimg'];
			$arr[6] = $rw['mv_bigimg'];
			
			$arr[7] = $rw['mv_content'];
			$arr[8] = $rw['mv_capacity'];
			$arr[9] = $rw['mv_year'];
			$arr[10]= $rw['mv_subtitles'];
			$arr[11]= $rw['mv_resolution'];
			$arr[12]= $rw['mv_price'];
			$arr[13]= $rw['mv_dateadd'];					
			$arr[14]= $rw['mv_status'];					
			$arr[15]= $rw['mv_homepage'];															
			$arr[16]= $rw['mv_active'];																		
		}		
		return $arr;
		$sql->free_result($result);
	}		

};
?>